import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import "element-ui/lib/theme-chalk/index.css";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/permission"; // permission control

import i18n from "./lang";
import Cookies from "js-cookie";

import { webServiceUrl, cloudBaseurl } from '@/api/baseURL'
Vue.prototype.$webServiceUrl = webServiceUrl;
Vue.prototype.$cloudBaseurl = cloudBaseurl;
// 引入echarts
import * as echarts from "echarts";
Vue.prototype.$echarts = echarts;

import $baseurl from '@/api/baseURL'
Vue.prototype.$baseurl = $baseurl;

import moment from "moment"; // 导入moment模块
moment.locale("zh-cn"); // 设置语言 或 moment.lang('zh-cn');
Vue.prototype.$moment = moment; // 赋值使用

Vue.prototype.dateToFormat = function (originDate) {
  const dt = new Date(originDate);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2, '0');
  const d = (dt.getDate() + '').padStart(2, '0');

  const hh = (dt.getHours() + '').padStart(2, '0');
  const mm = (dt.getMinutes() + '').padStart(2, '0');
  const ss = (dt.getSeconds() + '').padStart(2, '0');

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
}

Vue.prototype.dateToFormatTwo = function (originDate, format) {
  const dt = new Date(originDate);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2, '0');
  const d = (dt.getDate() + '').padStart(2, '0');
  if (format) {
    return moment(originDate).format(format);
  } else {
    return `${y}-${m}-${d}`;
  }
}

import Element from "element-ui";
Vue.use(Element, {
  size: Cookies.get("size") || "medium", // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
});

// 高德地图
import VueAMap from "vue-amap";
Vue.use(VueAMap);
// 初始化vue-amap
VueAMap.initAMapApiLoader({
  key: "a3b3a19aba313ad306dc7c6ef3b0e07a",
  plugin: [
    'AMap.Scale',
    'AMap.OverView',
    'AMap.ToolBar',
    'AMap.PolyEditor',
    'MarkerClusterer',
    'AMap.DistrictSearch',
    "AMap.ControlBar",
    "AMap.MapType", // 类别切换控件，实现默认图层与卫星图、实施交通图层之间切换的控制
    'AMap.Geocoder',
    'AMap.CircleEditor',
    "AMap.Geolocation",
    "AMap.Autocomplete",
    "AMap.PlaceSearch",
    "AMap.CitySearch",
    "AMap.MouseTool",
  ],
  // uiVersion: '1.1',
  v: "1.4.4"
});
window._AMapSecurityConfig = {
  securityJsCode: '0caff5ad2c9a3e2d388199d1b7939498'
}
// 引入拖拽组件
import VueDragResize from 'vue-drag-resize'
Vue.component('vue-drag-resize', VueDragResize)

Vue.config.productionTip = false;
// import 'default-passive-events'
// 图片
import EleUploadImage from "vue-ele-upload-image";
Vue.component(EleUploadImage.name, EleUploadImage);

import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import frameInRoutes from '@/router/routes'


import SearchForm from "@/components/searchForm";
import ElementTable from './components/Table'

Vue.component('SearchForm', SearchForm)
Vue.component('e-table', ElementTable)


import { mymixin } from "./utils/mymixin";
Vue.mixin(mymixin)
Vue.use(VueQuillEditor);
new Vue({
  el: "#app",
  router,
  store,
  i18n,
  created() {
    // 处理路由 得到每一级的路由设置
    this.$store.commit('page/init', frameInRoutes)
  },
  render: h => h(App)
});
